/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.jm.acionista.datamodel;

import br.jm.acionista.entity.Moeda;
import java.util.Comparator;

/**
 *
 * @author joao
 */
public class LazySorter implements Comparator<Moeda> {

    private String sortField;
    
    private boolean sortOrder;
    
    public LazySorter(String sortField, boolean sortOrder) {
        this.sortField = sortField;
        this.sortOrder = sortOrder;
    }

    public int compare(Moeda moeda1, Moeda moeda2) {
        try {
            Object value1 = Moeda.class.getField(this.sortField).get(moeda1);
            Object value2 = Moeda.class.getField(this.sortField).get(moeda2);

            int value = ((Comparable)value1).compareTo(value2);
            
            //return SortOrder.ASCENDING.equals(sortOrder) ? value : -1 * value;
            return 0;
        }
        catch(Exception e) {
            throw new RuntimeException();
        }
    }

}
